<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form id="rolePermissionsForm">
			<h:panelGrid style="width: 100%">
				<h:outputLabel value="Role Permissions" styleClass="outputTextTitle" />
				
				<h:panelGrid columns="2">
					<h:outputText value="Select Role: " />
					<p:selectOneMenu id="rolesMenu" value="#{rolePermissionsBean.selectedRoleId}" styleClass="selectOneMenu168pxFixedWidth">
						<f:ajax listener="#{rolePermissionsBean.roleSelectionListener}" render="@form"/>
						<f:selectItem itemValue="" itemLabel="" />
						<f:selectItems value="#{rolePermissionsBean.rolesMap}" />
					</p:selectOneMenu>
				</h:panelGrid>
				<p:watermark for="rolesMenu" value="Select a Role" />
				<h:panelGrid style="width: 100%;" rendered="#{rolePermissionsBean.renderRolePermissionTable}">
					<p:dataTable  value="#{rolePermissionsBean.rolePermissions}" var="row" style="width: 100%; border: none;">
						<p:column style="border: none;">    
							<h:outputText value="#{row.permission.displayName}" />
						</p:column>
						
						<p:column style="text-align: right; border: none;">
							<p:selectOneButton value="#{row.permitted}" >
								<f:ajax listener="#{rolePermissionsBean.changePermission}"></f:ajax>
								<f:attribute name="rolePermission" value="#{row}" />
								<f:selectItem itemLabel="Permitted" itemValue="Yes" />  
	            				<f:selectItem itemLabel="Not Permitted" itemValue="No" />  
							</p:selectOneButton>
						</p:column>
					</p:dataTable>
					
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>